const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  mode: 'production',
  entry: './src/index.js',
  output: {
    filename: 'index.[hash:4].js',
    // path必须是绝对目录
    path: path.resolve(__dirname, 'dist')
  },

  plugins: [
    new CleanWebpackPlugin({
      // cleanOnceBeforeBuildPatterns: ['*.js'] // 指定需要清除的文件类型，默认全部['**/*']
    }),
    new HtmlWebpackPlugin({
      template: './public/index.html',
      title: '我的页面', // <%= htmlWebpackPlugin.options.title %>
      filename: 'index.html',
      // minify: true
    })
  ]
}